package com.jax.de;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    
    public void setNumber(View view) {
    	EditText ed = (EditText)findViewById(R.id.editText1);
    	Button b = (Button)view;
    	if(!ed.getText().toString().equals("0")) {
    			ed.setText(ed.getText().toString() + b.getText().toString());
    		} 
    		else{
    				ed.setText(b.getText().toString());
    			} 
    }
    
    public void clearEdit(View view){
    	((EditText)findViewById(R.id.editText1)).setText("0");
    }
    
    public String calculate(String a, String b){
    	String result = "";
    	int len = a.length() - b.length();
    	if(len > 0){
    		b = zeroGenerator(len) + b;
    	}else{
    		if(len < 0){
    			a = zeroGenerator(Math.abs(len));
    		}
    	}
    	for(int i=a.length()-1; i <= 0; i--){
    		
    	}
    	return result;
    }
    
    private String zeroGenerator(int len){
    	String s = "";
    	for(int i=0; i<len; i++){
    		s += s + "0";
    	}
    	return s;
    }
}